import time
from random import choice
setGlobalDuration(30)

env = genAdsr()
w = genWaveform()

waveform(pitch=250, envelope=env, table=w, amplitude=.5)

proc = startCsound()

time.sleep(1)

def newWave():
    myStr = "f" + str(w) + " 0 8192 10 " + " ".join([str(choice([0,0,0,0,.2,.3,.5,.7,1])) for i in range(10)]) + "\n"
    print myStr
    sendCsoundMsg(myStr, proc)

ti1 = pattern(.5, newWave, [1])
ti1.start()
ti1.play()


